<uieip type="page" value="login" debug="true" timeout="5000"></uieip>
<uieip type="reg" value="console"></uieip>
<!DOCTYPE html>
<html>

<head>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/src/yqwin.min" cache="false"></uieip>
    <title>yqForeignKey</title>
</head>

<body>
    <h1>yqForeignKey</h1>
    <select id="cc" style="width:250px;"></select>
    <p></p>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:setValue()">setValue</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:getValue()">getValue</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:clearun()">clearun</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:disable()">disable</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:enable()">enable</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy()">destroy</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:init_1()">init_1</a>
    <p></p>
    <table>
        <tr>
            <td width="300px">
            
            </td>
            <td>
                <select id="cc2" style="width:250px;"></select>
            </td>
        </tr>
    </table>
    
    <p></p>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:setValue2()">setValue</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:getValue2()">getValue</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:clearun2()">clearun</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:disable2()">disable</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:enable2()">enable</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy2()">destroy</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:init_2()">init_2</a>
    
    <p></p>
    <input id="cs1" type="text" style="width:300px">
    <script type="text/javascript" src="/yqwin/src/yq.nforeignkey.js"></script>
    <script>
        var dbname="yqbase";

        $(function () {
            $.yqDbList({ajaxUrl: "_db.html"}, 
                function (data) {     
                    if (data.error == 0) {
                        dbname=data.rows[0].name;
                        init_1();
                        init_2();

                        init2_1();
                    }else{
                        alert(data.info);
                    }
                });       
        });

        function init_1(){
            $("#cc").yqForeignKey({
                ajaxUrl: "/_db.html", //ajax地址
                displayType: 1,                 //显示类型, 1--下拉列表 2--查询窗体
                dbname: dbname,                 //数据库
                tbname: "ab_test_move",         //表
                tempno: 100,                    //实例 
                addWhere: "",                   //额外条件
                order: "queue",                 //排序
                isPage: false,                  //分页
                pageSize: 5,
                valueMember: "sid",               //值字段
                displayMember: "textbox",         //显示字段
            });
        }
        
        function init_2(){
            $("#cc2").yqForeignKey({
                ajaxUrl: "/_db.html", //ajax地址
                panelWidth: 600,
                panelHeight: 450,
                displayType: 2,                 //显示类型, 1--下拉列表 2--查询窗体
                dbname: dbname,               //数据库
                tbname: "ab_test_m",        //表
                tempno: 100,                    //实例 
                addWhere: "",                   //额外条件
                order: "",                      //排序
                isPage: true,                   //分页
                pageSize: 5,
                valueMember: "sid",             //值字段
                displayMember: "textbox",       //显示字段
            });
        }

        function setValue() {
            $("#cc").yqForeignKey("setValue", "a2c255b6-f2a0-458d-a24a-fe90af15da3d");
        }

        function getValue() {
            var val = $("#cc").yqForeignKey("getValue");
            if (val == "") {
                console.log("空");
            }
            else if (val == null) {
                console.log("null");
            }
            console.log("getValue", $("#cc").yqForeignKey("getValue"));
        }

        function clearun() {
            $("#cc").yqForeignKey("clear");
        }

        function disable() {
            $("#cc").yqForeignKey("disable");
        }
        function enable() {
            $("#cc").yqForeignKey("enable");
        }

        function destroy() {
            $("#cc").yqForeignKey("destroy");
        }


        function setValue2() {
            $("#cc2").yqForeignKey("setValue", "a2c255b6-f2a0-458d-a24a-fe90af15da3d");
        }

        function getValue2() {
            var val = $("#cc2").yqForeignKey("getValue");
            if (val == "") {
                console.log("空");
            }
            else if (val == null) {
                console.log("null");
            }
            console.log("getValue", $("#cc2").yqForeignKey("getValue"));
        }

        function clearun2() {
            $("#cc2").yqForeignKey("clear");
        }

        function disable2() {
            $("#cc2").yqForeignKey("disable");
        }
        function enable2() {
            $("#cc2").yqForeignKey("enable");
        }

        function destroy2() {
            $("#cc2").yqForeignKey("destroy");
        }


        function init2_1(){
            $("#cs1").yqNForeignKey({
                ajaxUrl: "/_db.html", //ajax地址
                panelWidth: 600,
                panelHeight: 580,
                dbname: dbname,                 //数据库
                tbname: "ab_test_move",         //表
                tempno: 100,                    //实例 
                addWhere: "",                   //额外条件
                order: "queue",                 //排序
                isPage: false,                  //分页
                pageSize: 5,
                valueMember: "sid",               //值字段
                displayMember: "textbox",         //显示字段
            });
            
        }
        

    </script>
    
</body>

</html>